<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Accessing Local Data &mdash; Documentation</title>
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Documentation" href="index.html" /> 
  </head>
  <body>
    <div style="background-color: #FFF; text-align: left; padding: 8px 0px"><img src="_static/banner300910.gif"></div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li><a href="index.html">Documentation</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/local_data.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="accessing-local-data">
<h1>Accessing Local Data<a class="headerlink" href="#accessing-local-data" title="Permalink to this headline">¶</a></h1>
<p>Local records are maintained in the <a class="reference external" href="glossary.html#term-locals"><em class="xref">locals</em></a> dictionary. Some useful functions to access local data:</p>
<dl class="function">
<dt id="LocalDB.add">
<tt class="descclassname">LocalDB.</tt><tt class="descname">add</tt><big>(</big><em>dt</em>, <em>dn</em><big>)</big><a class="headerlink" href="#LocalDB.add" title="Permalink to this definition">¶</a></dt>
<dd>Add a new record to <cite>locals</cite></dd></dl>

<dl class="function">
<dt id="LocalDB.delete_doc">
<tt class="descclassname">LocalDB.</tt><tt class="descname">delete_doc</tt><big>(</big><em>dt</em>, <em>dn</em><big>)</big><a class="headerlink" href="#LocalDB.delete_doc" title="Permalink to this definition">¶</a></dt>
<dd>Delete a record and all child records from <cite>locals</cite></dd></dl>

<dl class="function">
<dt id="LocalDB.set_default_values">
<tt class="descclassname">LocalDB.</tt><tt class="descname">set_default_values</tt><big>(</big><em>doc</em><big>)</big><a class="headerlink" href="#LocalDB.set_default_values" title="Permalink to this definition">¶</a></dt>
<dd>Set default values for the given <cite>doc</cite>. Will only work if the metadata (<cite>DocType</cite>) is also loaded</dd></dl>

<dl class="function">
<dt id="LocalDB.create">
<tt class="descclassname">LocalDB.</tt><tt class="descname">create</tt><big>(</big><em>dt</em>, <em>n</em><big>)</big><a class="headerlink" href="#LocalDB.create" title="Permalink to this definition">¶</a></dt>
<dd>Create a new record and set default values. If n is null, n is set as &#8220;Unsaved ..&#8221;</dd></dl>

<dl class="function">
<dt id="LocalDB.delete_record">
<tt class="descclassname">LocalDB.</tt><tt class="descname">delete_record</tt><big>(</big><em>dt</em>, <em>dn</em><big>)</big><a class="headerlink" href="#LocalDB.delete_record" title="Permalink to this definition">¶</a></dt>
<dd>Mark for deletion (called when a row is deleted from the table)</dd></dl>

<dl class="function">
<dt id="LocalDB.get_default_value">
<tt class="descclassname">LocalDB.</tt><tt class="descname">get_default_value</tt><big>(</big><em>fieldname</em>, <em>fieldtype</em>, <em>default</em><big>)</big><a class="headerlink" href="#LocalDB.get_default_value" title="Permalink to this definition">¶</a></dt>
<dd><p>Get default value for the given field details for <cite>default</cite> keyword</p>
<ul class="simple">
<li>If <cite>default</cite> is &#8216;__user&#8217; or &#8216;_Login&#8217; - return username</li>
<li>If <cite>default</cite> is &#8216;Today&#8217; or &#8216;__today&#8217; - return today&#8217;s date</li>
<li>Return <cite>default</cite> if <cite>default</cite> is not null.</li>
<li>If field name matches user or system default, then return the default</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="LocalDB.add_child">
<tt class="descclassname">LocalDB.</tt><tt class="descname">add_child</tt><big>(</big><em>doc</em>, <em>childtype</em>, <em>parentfield</em><big>)</big><a class="headerlink" href="#LocalDB.add_child" title="Permalink to this definition">¶</a></dt>
<dd>Return a child record, with parentfield set (optionally). Called when a row is added to the table</dd></dl>

<dl class="function">
<dt id="LocalDB.copy">
<tt class="descclassname">LocalDB.</tt><tt class="descname">copy</tt><big>(</big><em>dt</em>, <em>dn</em>, <em>from_amend</em><big>)</big><a class="headerlink" href="#LocalDB.copy" title="Permalink to this definition">¶</a></dt>
<dd>Create and return a copy of record specified by <cite>dt</cite> and <cite>dn</cite>. Called by <cite>Copy</cite> and <cite>Amend</cite></dd></dl>

<dl class="function">
<dt id="make_doclist">
<tt class="descname">make_doclist</tt><big>(</big><em>dt</em>, <em>dn</em><big>)</big><a class="headerlink" href="#make_doclist" title="Permalink to this definition">¶</a></dt>
<dd>Return the required record and all child records from <cite>locals</cite>.</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li><a href="index.html">Documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Rushabh Mehta.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
    </div>
  </body>
</html>